// 导入axios实例
import httpRequest from '../request/index'


// 获取电视剧全部年份
export function getYears() {
    return httpRequest({
        url: '/teleplay/years',
        method: 'get',
    });
}


// 获取全部电视剧（年份分组）
export function getAll() {
    return httpRequest({
        url: '/teleplay/all',
        method: 'get',
    });
}

// 获取全部电视剧（不分组）
export function getAllTeleplay() {
    return httpRequest({
        url: '/teleplay/listall',
        method: 'get',
    });
}


// 分页获取电视剧列表数据
export function getList(pageSize, pageNum) {
    return httpRequest({
        url: `/teleplay?pageSize=${pageSize}&pageNum=${pageNum}`,
        method: 'get',
    });
}


// 获取电视剧全部集数链接
export function getTeleplayLinks(id) {
    return httpRequest({
        url: `/teleplay/vlist?tid=${id}`,
        method: 'get',
    });
}


// 添加电视剧
export function addTeleplay(teleplay) {
    return httpRequest({
        baseURL: '/admin',
        url: `/teleplay/add`,
        method: 'post',
        data: teleplay,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}


// 编辑电视剧
export function editTeleplay(id, teleplay) {
    return httpRequest({
        baseURL: '/admin',
        url: `/teleplay/edit/${id}`,
        method: 'put',
        data: teleplay,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}


// 删除电视剧
export function deleteTeleplay(id) {
    return httpRequest({
        baseURL: '/admin',
        url: `/teleplay/${id}`,
        method: 'delete',
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}


// 写评语
export function doTeleplayComment(id, comment) {
    return httpRequest({
        baseURL: '/admin',
        url: `/teleplay/comment/${id}`,
        method: 'post',
        data: comment,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}
